check if duplicate element is present in an array